/*
 * Util.h
 *
 *  Created on: 2011-5-27
 *      Author: yangentao@gmail.com
 */

#ifndef UTIL_H_
#define UTIL_H_

#include "../pre.h"

namespace util {

template<typename T>
void FreeObject(T*& p){
	delete p;
	p = nullptr;
}

template<typename T>
void FreeArray(T*& p){
	delete[] p;
	p = nullptr;
}
inline unsigned int ValueOfHex(const char ch) {
	if (ch >= '0' && ch <= '9')
		return ch - '0';
	else if (ch >= 'A' && ch <= 'F')
		return ch - 'A' + 10;
	else if (ch >= 'a' && ch <= 'f')
		return ch - 'a' + 10;
	else
		return 0;
}

} /* namespace util */
#endif /* UTIL_H_ */
